﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Asteriods
{
    class Asteriod : GameObject
    {
        private int size;
        public int Size
        {
            get { return size; }
            set { size = value; }
        }
        public Asteriod(Game game, string imagepath)
            : base(game, imagepath)
        {
        }
        public virtual void OnCollision(List<Asteriod> activeAsteriods, List<Asteriod> inactiveAsteriods, int currentAsteriod, Game game, string imagepath)
        {
        }
        public void moveLists(List<Asteriod> originalList, List<Asteriod> newList, int objectnumber)
        {
            newList.Add(originalList[objectnumber]);
            originalList.Remove(originalList[objectnumber]);
        }
    }
    class LargeAsteriod : Asteriod
    {
        public LargeAsteriod(Game game, string imagepath)
            : base(game, imagepath)
        {
            SetNewScale(1.25f);
        }
        public override void OnCollision(List<Asteriod> activeAsteriods, List<Asteriod> inactiveAsteriods, int currentAsteriod, Game game, string imagepath)
        {
            for (int i = 0; i < 3; i++)
            {
                Rotation += 2.356f;
                Asteriod ast = new MediumAsteriod(game, imagepath);
                Vector2 NewVelocity = new Vector2((float)Math.Cos(Rotation), (float)Math.Sin(Rotation));
                ast.SetNewPositonVelocityandRotation(Position, NewVelocity, Rotation);
                activeAsteriods.Add(ast);
            }
            moveLists(activeAsteriods, inactiveAsteriods, currentAsteriod);
            base.OnCollision(activeAsteriods, inactiveAsteriods, currentAsteriod, game, imagepath);
        }
    }
    class MediumAsteriod : Asteriod
    {
        public MediumAsteriod(Game game, string imagepath)
            : base(game, imagepath)
        {
            SetNewScale(0.8f);
        }
        public override void OnCollision(List<Asteriod> activeAsteriods, List<Asteriod> inactiveAsteriods, int currentAsteriod, Game game, string imagepath)
        {
            for (int i = 0; i < 3; i++)
            {
                Rotation += 2.356f;
                Asteriod ast = new SmallAsteriod(game, imagepath);
                Vector2 NewVelocity = new Vector2((float)Math.Cos(Rotation), (float)Math.Sin(Rotation));
                ast.SetNewPositonVelocityandRotation(Position, NewVelocity, Rotation);
                activeAsteriods.Add(ast);
            }
            activeAsteriods.Remove(activeAsteriods[currentAsteriod]);
            base.OnCollision(activeAsteriods, inactiveAsteriods, currentAsteriod, game, imagepath);
        }
    }
    class SmallAsteriod : Asteriod
    {
        public SmallAsteriod(Game game, string imagepath)
            : base(game, imagepath)
        {
            SetNewScale(0.5f);
        }
        public override void OnCollision(List<Asteriod> activeAsteriods, List<Asteriod> inactiveAsteriods, int currentAsteriod, Game game, string imagepath)
        {
            activeAsteriods.Remove(activeAsteriods[currentAsteriod]);
            base.OnCollision(activeAsteriods, inactiveAsteriods, currentAsteriod, game, imagepath);
        }
    }
}
